<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>跳转</button>
    <button>刷新</button>
    <button>强制刷新</button>
    <script>
        var oBtn = document.querySelectorAll('button')[0];
        var oBtn2 = document.querySelectorAll('button')[1];
        var oBtn3 = document.querySelectorAll('button')[2];
        oBtn.onclick = function () {
            if (confirm('确定跳转么？')) {
                // 有历史记录
                // location.href = 'http://baidu.com';
                // location.assign('http://baidu.com');

                // 没有历史记录
                location.replace('http://baidu.com');
            } else {
                console.log('什么没发生')
            }
        }

        oBtn2.onclick = function(){
            location.reload();
        }

        oBtn3.onclick = function(){
            location.reload(true);
        }
    </script>
</body>

</html>